#include "EventNode.h"

#include <stdio.h>
#include <stdlib.h>

void
event_node_finalize(EventNode *self)
{
	if (self->data_destory)
		self->data_destory(self->data);
	if (self->next)
		event_object_unref(self->next);
}

void
event_node_init(EventNode *self)
{
	return_if_fail(self != NULL, event_node_init);

	event_object_init(EVENT_OBJECT(self));

	self->next	   = NULL;
	self->data	   = NULL;
	self->data_destory = NULL;
}

EventNode *
event_node_new()
{
	EventNode *object = MALLOC_NEW(EventNode);

	event_node_init(object);
	event_object_set_finalize(object, FINALIZE(event_node_finalize));

	return object;
}

void
event_node_set_data(EventNode *self, epointer data,
		    void (*data_destory)(epointer))
{
	return_if_fail(self != NULL, event_node_set_data);

	self->data	   = data;
	self->data_destory = data_destory;
}

void
event_node_set_next(EventNode *self, EventNode *next)
{
	return_if_fail(self != NULL, event_node_set_next);
	self->next = next;
}
